package com.hl.toolkit.pay.handler;

import com.tycoin.ErrorCode;
import com.tycoin.app.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
public class SimpleErrorController extends BaseController {
	private final Logger logger = LoggerFactory
			.getLogger(SimpleErrorController.class);

	@Value("${common.path:COMMON}")
	private String commonPath;

 

 
	@RequestMapping(value = "/400")
	public String handle400(Model model, HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("handle 400 : ");

	//	String appCode = getAppCode(request, response);

		int errorCode = ErrorCode.SYSTEM_ERROR;
		model.addAttribute("errorCode", errorCode);
		model.addAttribute("errorMessage", getMessage(errorCode));
		return  "ERROR";
	}

	@RequestMapping(value = "/404")
	public String handle404(Model model, HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("handle 404 : ");

 
		int errorCode = ErrorCode.SYSTEM_PAGE_NOT_FOUND;
		model.addAttribute("errorCode", errorCode);
		model.addAttribute("errorMessage", getMessage(errorCode));
		return"ERROR";
	}

	@RequestMapping(value = "/500")
	public String handle500(Model model, HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("handle 500 : ");
  
		int errorCode = ErrorCode.SYSTEM_ERROR;
		model.addAttribute("errorCode", errorCode);
		model.addAttribute("errorMessage", getMessage(errorCode));
		return   "ERROR";
	}
}